<?
require_once('../mod_config.php');

$moduol_name = 'Tìm kiếm';
/*-------------------- Class Search -----------------------*/
class search{
   var $total = 0;
   /**
    * getList
    * 
    * @param int $limit So luong ban ghi tra ve
    * @param int $start Vi tri ban ghi bat dau lay
    * @return array  Mang cac tu khoa
   */
   static public function getList($start=0,$limit){
      $array = array();
      $limit = ($limit > 0) ? $limit : 20;
      $db_query = new db_query(' SELECT   
                                    search_id,
                                    search_text,
                                    search_keyword,
                                    search_date,
                                    search_count
                                 FROM 
                                    search
                                 ORDER BY 
                                    search_count DESC,
                                    search_id DESC
                                 LIMIT '. $start . "," . $limit);
      $array = $db_query->resultArray();
      unset($db_query);
      return $array;
   }
   
   /**
    * getTotalVideo
    * @return int Tong so video co trong bang 
   */
   static public function getTotal(){
      $count = 0;
      $db_count = new db_query("SELECT count(search_id) as count FROM search"); 
      $row = mysql_fetch_assoc($db_count->result);
      $count = (isset($row['count'])) ? $row['count'] : $count;
      return $count;
   }
   
}
$search = new search();     
?>